package com.crm.service.impl.sys;

import com.crm.dao.mapper.customMapper.sys.UserInfoCustomMapper;
import com.crm.dao.mapper.sys.EducationalExperienceMapper;
import com.crm.dao.mapper.sys.UserInfoMapper;
import com.crm.model.entity.sys.EducationalExperience;
import com.crm.model.entity.sys.EducationalExperienceExample;
import com.crm.model.entity.sys.UserInfo;
import com.crm.model.entity.sys.UserInfoExample;
import com.crm.model.vo.user.UserInfoVO;
import com.crm.service.sys.UserEducationalExperienceDbService;
import com.crm.service.sys.UserInfoDbService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 教育经历
 * @author baijian
 * @date 2020/10/9 9:35
 */
@Service
public class UserEducationalExperienceDbServiceImpl implements UserEducationalExperienceDbService {

    @Autowired
    private EducationalExperienceMapper educationalExperienceMapper;

    /**
     * 根据用户id查询教育经历
     * @param userId 用户id
     * @return
     */
    @Override
    public List<EducationalExperience> educationalExperienceList(String userId) {
        EducationalExperienceExample educationalExperienceExample = new EducationalExperienceExample();
        EducationalExperienceExample.Criteria criteria = educationalExperienceExample.createCriteria();
        criteria.andUserIdEqualTo(userId);
        List<EducationalExperience> list = educationalExperienceMapper.selectByExample(educationalExperienceExample);
        return list;
    }

    /**
     * 个人信息-新增教育经历
     * @param educationalExperience 教育经历实体
     * @return
     */
    @Override
    public Boolean addEducationalExperience(EducationalExperience educationalExperience) {
        Boolean result = false;
        int num = educationalExperienceMapper.insertSelective(educationalExperience);
        if(num>0){
            result = true;
        }
        return result;
    }

    @Override
    public EducationalExperience getEducationalExperienceById(String educationalExperienceId) {
        return educationalExperienceMapper.selectByPrimaryKey(educationalExperienceId);
    }

    /**
     * 个人信息-修改教育经历
     * @param educationalExperience 教育经历实体
     * @return
     */
    @Override
    public Boolean updateEducationalExperience(EducationalExperience educationalExperience) {
        Boolean result = false;
        int num = educationalExperienceMapper.updateByPrimaryKeySelective(educationalExperience);
        if(num>0){
            result = true;
        }
        return result;
    }
}
